<%@ page language="java" pageEncoding="GBK" %>
<%@ page contentType="text/html; charset=GBK" language="java"%>
<%@ page import="com.hd123.rumba.request.Dictionary"%>

<%@ page import="com.hd123.rumba.domain.CDomain"%>
<%@ page import="com.hd123.rumba.domain.IDomain"%>
<%@ page import="com.hd123.rumba.domain.biz.IBDomainMgr"%>
<%@ page import="com.hd123.rumba.runtime.NamingMgr"%>
<%
Dictionary dd = (Dictionary)request.getAttribute("dd");

String viewName = (String) dd.get("viewName");

IBDomainMgr bdmMgr = (IBDomainMgr) NamingMgr.getInstance().lookupMgr(IBDomainMgr.class);
%>

<script language=javascript>
function buildQuery(qry, codeLike) {
	qry.service = "<%=viewName%>.query";
	qry.addFrom("<%=bdmMgr.getPerzMgr().lookupClass(IDomain.class)%>", "d");
	qry.addSelect("d.uuid", "uuid");
	qry.addSelect("d.code", "code");
	qry.addSelect("d.name", "name");
	if (isDefined(codeLike) && trimString(codeLike) != "")
		qry.setWhere(RSCE.cond("d.code like ?", codeLike, RSCE.WC_RIGHT));
	qry.addOrder("d.code", RQuery.ORDER_ASC);
}

function buildGrid(grid) {
	grid.addColumnDef(new RQColumnDef({caption: "uuid", 
		fieldName: "uuid", dataType: RQColumnDef.DT_TEXT, hidden: true}));
	grid.addColumnDef(new RQColumnDef({caption: "<%=CDomain.CAPTION_CODE%>", 
		fieldName: "code", dataType: RQColumnDef.DT_TEXT}));
	grid.addColumnDef(new RQColumnDef({caption: "<%=CDomain.CAPTION_NAME%>", 
		fieldName: "name", dataType: RQColumnDef.DT_TEXT}));
}
</script>
